Reading Characteristic Data

HealthKit stores characteristics as immutable personal attributes, such as biological sex, date of birth, blood type, skin type, wheelchair usage, and activity move mode. These values are typically entered by the user in the Health app and rarely change.

The Scripting app provides global asynchronous APIs for accessing these values.


Supported Characteristics

You can read the following characteristics:

Characteristic API Return Type
Date of birth Health.dateOfBirth() DateComponents
Biological sex Health.biologicalSex() HealthBiologicalSex enum
Blood type Health.bloodType() HealthBloodType enum
Fitzpatrick skin type Health.fitzpatrickSkinType() HealthFitzpatrickSkinType enum
Wheelchair use status Health.wheelchairUse() HealthWheelchairUse enum
Activity move mode Health.activityMoveMode() HealthActivityMoveMode enum

1. Read Date of Birth

1const birthDate = await Health.dateOfBirth()
2console.log(`Year: ${birthDate.year}, Month: ${birthDate.month}, Day: ${birthDate.day}`)

Returned object conforms to DateComponents:

1{
2  era?: number
3  year?: number
4  month?: number
5  day?: number
6  hour?: number
7  minute?: number
8  second?: number
9  weekday?: number
10  ...
11}

2. Read Biological Sex

1const sex = await Health.biologicalSex()
2
3switch (sex) {
4  case HealthBiologicalSex.female:
5    console.log("Female")
6    break
7  case HealthBiologicalSex.male:
8    console.log("Male")
9    break
10  case HealthBiologicalSex.other:
11    console.log("Other")
12    break
13  case HealthBiologicalSex.notSet:
14    console.log("Not Set")
15    break
16}

3. Read Blood Type

1const blood = await Health.bloodType()
2
3switch (blood) {
4  case HealthBloodType.aPositive:
5    console.log("A+")
6    break
7  case HealthBloodType.oNegative:
8    console.log("O-")
9    break
10  // ... other values
11  default:
12    console.log("Not Set")
13}

4. Read Fitzpatrick Skin Type

1const skinType = await Health.fitzpatrickSkinType()
2
3switch (skinType) {
4  case HealthFitzpatrickSkinType.I:
5    console.log("Type I: Very fair")
6    break
7  case HealthFitzpatrickSkinType.VI:
8    console.log("Type VI: Deeply pigmented dark brown to black")
9    break
10  default:
11    console.log("Not Set")
12}

5. Read Wheelchair Use Status

1const wheelchair = await Health.wheelchairUse()
2
3if (wheelchair === HealthWheelchairUse.yes) {
4  console.log("User uses a wheelchair")
5} else if (wheelchair === HealthWheelchairUse.no) {
6  console.log("User does not use a wheelchair")
7} else {
8  console.log("Not Set")
9}

6. Read Activity Move Mode

1const mode = await Health.activityMoveMode()
2
3if (mode === HealthActivityMoveMode.activeEnergy) {
4  console.log("Tracking by active energy burned")
5} else if (mode === HealthActivityMoveMode.appleMoveTime) {
6  console.log("Tracking by Apple Move Time")
7}

Error Handling

Each method may throw an error if:

  • The characteristic is not set by the user
  • The permission is denied
  • HealthKit is unavailable

Example:

1try {
2  const sex = await Health.biologicalSex()
3  console.log(sex)
4} catch (err) {
5  console.error("Failed to read biological sex:", err)
6}

Summary

You can access personal attributes using the following global APIs:

1await Health.dateOfBirth()
2await Health.biologicalSex()
3await Health.bloodType()
4await Health.fitzpatrickSkinType()
5await Health.wheelchairUse()
6await Health.activityMoveMode()

These values are static and reflect the user’s personal configuration in the Health app. Be sure to handle missing or unset values gracefully.